#pragma once


#include "GEnginePCH.h"

#include "Support.h"

class Terrain
{
public:

	Terrain(void);
	~Terrain(void);
	void Init( const D3DXMATRIX& matVP );
	void Render( const D3DXMATRIX& matVP );
	void loadTerrain(void);
	void invalidateDeviceObjects(void);
	bool checkCollision( int mouseX, int mouseY , const D3DXMATRIX &matView, const D3DXMATRIX &matProj, D3DXVECTOR3 &hitPoint );
	float GetHeight( float x, float z );

private:
	const D3DXVECTOR3 m_vecScale;
	const DWORD TERRAIN_X ;
	const DWORD TERRAIN_Z ;

	
	LPDIRECT3DTEXTURE9      m_pTexture;

    LPDIRECT3DVERTEXBUFFER9 m_pTerrainVB; //vertex buffer
    LPDIRECT3DINDEXBUFFER9  m_pTerrainIB; //index buffer

    DWORD                   m_dwTerrainVertices, //vertex count
                            m_dwTerrainPrimitives; //primitive count
	VERTEX *pVertexData; //pointer to vertex

	short* pIndexData; //pointer to index
	short *aHeightMap; // system memory copy of the height array
	short* indexBuff;	// system memory copy of the index buffer - TODO : chiar am nevoie de asta ???

	//float rotateY;	
	D3DXMATRIX World;
};
